<template>
  <div class="nameList_box">
    <div class="first_box">
      <div class="first" v-for='item,index in collectionList' @click="pushToDetail(index)">
        <div class="first_img">
          <img :src="item.cover"/>
        </div>
        <div class="first_text">
          <div class="text_one">
            <div class="text_one_one">
              <span style="font-size: 20px">{{item.realName}}</span>
              <span>{{item.sex == 1 ? '男' : '女'}}</span>
              <span>{{item.score}}</span>
            </div>
            <div class="text_one_two" @click.stop @click="onDeleteCollect(item.collectID)">
              <img src="../../assets/collect.jpg" alt/>
            </div>
          </div>
          <div class="text_two">
            <div class="text_one_one">
              <span>{{item.age}}岁</span> <span>{{item.height}}cm</span> <span>{{item.weight}}kg</span>
            </div>
            <span></span>
          </div>
          <p>职业：{{item.jobList}}</p>
          <p>地址：{{item.cityList}}</p>
          <p>标签：{{item.typeList}}</p>
        </div>
        <div>
        </div>
      </div>
      <div class="pagination">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page.sync="currentPage4"
          :page-size="12"
          layout="prev, pager, next, jumper"
          :total="rowsCount"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        activeName: "first",
        collectionList: [],
        rowsCount: 0,
        page: 1,
      };
    },
    mounted: function () {
      this.getCollectionActorsList();
    },
    methods: {
      handleClick(tab, event) {
        console.log(tab, event);
      },
      getCollectionActorsList: function () {
        let self = this;
        let obj = {
          token: self.globalData.token,
          pageSize: '12',
          page: this.page,
        };
        self.$post("/User/getUserCollect", obj).then(res => {
          if (res.code === "200") {
            self.collectionList = res.data.userList;
            self.rowsCount = res.data.rowsCount;
          } else {
            self.$message.error(res.message);
          }
        });
      },
      pushToDetail(index) {
        let routeData = this.$router.resolve({
          path: "/newArtistDetail",
          query: {uid: this.collectionList[index].uid, isOperation: this.collectionList[index].isOperation}
        });
        window.open(routeData.href, '_blank');
      },
      onDeleteCollect(collectID) {
        let self = this;
        let obj = {
          token: self.globalData.token,
          collectID: collectID
        };
        self.$fetch("/User/deleteCollect", obj).then(res => {
          if (res.code === "200") {
            self.$message("取消收藏成功");
            self.getCollectionActorsList();
          } else {
            self.$message.error(res.message);
          }
        });
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
        this.page = val;
        this.getCollectionActorsList();
      }
    },
  };
</script>

<style lang="less" scoped>
  .nameList_box {
    width: 80%;
    margin: auto;
    font-size: 12px;
    .first_box {
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      margin-top: 20px;
      width: 100%;
      .first {
        position: relative;
        margin-top: 40px;
        margin-left: 20px;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        flex: 0 1 calc(33% - 30px);
        height: auto;
        border-radius: 4px;
        border: 1px solid #f0f0f0;
        box-shadow: 0 3px 13px 0px rgba(0, 0, 0, 0.1);
        .first_img {
          width: 40%;
          position: relative;
          top: -10px;
          left: -10px;
          height:auto;
          img {
            top: -10px;
            left: -10px;
            height: auto;
            width: 100%;
            border-radius: 10px;
          }
        }
        .first_text {
          width: 60%;
          height: 100%;
          .text_one {
            padding: 10px 15px 0px 0px;
            // width: 100%;
            display: flex;
            flex-direction: row;
            align-content: center;
            justify-content: space-between;
            img {
              width: 26px;
              height: auto;
            }
            .text_one_one {
              display: flex;
              align-items: center;
              justify-content: space-between;
              width: 100%;
            }
          }
          .text_two {
            padding: 10px 15px 0px 0px;

            display: flex;
            flex-direction: row;
            align-items: center;
            justify-content: space-between;
          }
        }
        .out {
          border-top: 1px solid #f0f0f0;
          width: 100%;
          height: 36px;
          padding-right: 15px;
          text-align: right;
          line-height: 30px;
        }
      }
    }
  }

  p {
    display: -webkit-box;
    /*! autoprefixer: off */
    -webkit-box-orient: vertical;
    /* autoprefixer: on */
    -webkit-line-clamp: 1;
    overflow: hidden;
    padding-right: 10px;
    text-overflow: ellipsis;
  }
</style>
